﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VRB_0._1
{
    class Button : AnimatedObject
    {
        public Animation OnAnimation, OffAnimation; //currentAnimation
        public State currentState;
        public float ButtonStartX;

        public enum State
        {
            ON, OFF
        }

        public void Initialize(Viewport Viewport, ContentManager Content, Vector2 position, State startState)
        {
            ButtonStartX = position.X;
            OnAnimation = new Animation();
            Texture2D OnTexture = Content.Load<Texture2D>("buttonpressedlowres");
            OnAnimation.Initialize(OnTexture, position, 75, 6, 0, 0, 0, 1, 600, Color.White, 1f, true, true);

            OffAnimation = new Animation();
            Texture2D OffTexture = Content.Load<Texture2D>("buttonunpressedlowres");
            OffAnimation.Initialize(OffTexture, position, 75, 16, 0, 0, 0, 1, 600, Color.White, 1f, true, true);

            currentState = startState;
            //currentAnimation = OnAnimation;
            if (currentState == State.ON)
            {
                base.Initialize(Viewport, OnAnimation, position, Startdirection);
            }
            else
            {
                base.Initialize(Viewport, OffAnimation, position, Startdirection);
            }
        }
        public override void Update(GameTime gameTime)
        {
            //currentAnimation.Update(gameTime);
            if (currentState == State.ON)
            {
                OnAnimation.Position = Position;
                OnAnimation.Update(gameTime);
            }
            else
            {
                OffAnimation.Position = Position;
                OffAnimation.Update(gameTime);
            }
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            //currentAnimation.Draw(spriteBatch);
            if (currentState == State.ON)
                OnAnimation.Draw(spriteBatch);
            else
                OffAnimation.Draw(spriteBatch);
        }
        public void changeState()
        {
            if (currentState == State.ON)
                currentState = State.OFF;
            else
                currentState = State.ON;
        }
        public override void Changeposition(float MoveSpeed)
        {
            OnAnimation.Position.X -= MoveSpeed;
            OffAnimation.Position.X -= MoveSpeed;
        }
        public override void Restart()
        {
            OnAnimation.Position.X = ButtonStartX;
            OffAnimation.Position.X = ButtonStartX;
            
        }

        //public override Vector2 GetPositions()
        //{
        //    return OnAnimation.Position;
        //}

        //public override void ChangeState(Button.State State)
        //{
        //    currentState = State;
        //}
    }
}
